import 'package:flutter/material.dart';
import 'package:love_app/common/su.dart';
import 'package:love_app/common/su_icon.dart';
import 'package:love_app/providers/share_provider.dart';
import 'package:love_app/routes/application.dart';
import 'package:love_app/routes/routes.dart';
import 'package:provider/provider.dart';

class MineBottom extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final ShareProvider shareProvider =
        Provider.of<ShareProvider>(context, listen: false);
    Color color = shareProvider.textColor;
    return Container(
      width: Su().w(706),
      margin: EdgeInsets.only(
        top: Su().h(18),
      ),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(Su().w(20)),
      ),
      child: Column(
        children: <Widget>[
          _buildItem(color, SuIcon.yaoqing, "邀请好友获补签卡", "", context),
          _buildItem(color, SuIcon.setting, "设置", "", context),
          _buildItem(color, SuIcon.five_star, "给五星好评", "", context),
          _buildItem(color, SuIcon.caogaoxiang, "草稿箱", "", context),
          _buildItem(color, SuIcon.kefu_zhongxing, "客服中心", "", context),
          _buildItem(color, Icons.android, "测试中心", Routes.testCenter, context),
        ],
      ),
    );
  }

  // 构建每一个item
  Widget _buildItem(
      Color color, IconData iconData, String name, String routeName, BuildContext context) {
    return InkWell(
      onTap: (){
        Application.router.navigateTo(context, routeName);
      },
      child: Container(
        height: Su().w(94.4),
        child: Row(
          children: <Widget>[
            _itemLeftIcon(color, iconData),
            _itemText(name),
            _itemRughtIcon(color),
          ],
        ),
      ),
    );
  }

  // 左边的图标
  Widget _itemLeftIcon(Color color, IconData iconData) {
    return Container(
      padding: EdgeInsets.only(
        left: Su().w(26),
        right: Su().w(34),
      ),
      child: Icon(
        iconData,
        color: color,
        size: Su().w(32),
      ),
    );
  }

  // 文字
  Widget _itemText(String name) {
    return Expanded(
      child: Text(
        name,
        style: Su().textStyle(Color.fromRGBO(38, 38, 38, 1), 30),
      ),
    );
  }

  // 右边的图标
  Widget _itemRughtIcon(Color color) {
    return Container(
      padding: EdgeInsets.only(
        right: Su().w(10),
      ),
      child: Icon(
        Icons.navigate_next,
        color: color,
        size: Su().w(50),
      ),
    );
  }
}
